package com.atguigu.lease.common.content;

/**
 * projectName: com.atguigu.lease.common.content
 *
 * @author: wangs
 * description:
 */

// 将对象和当前线程绑定的类
public class LoginUserContext {
    private static ThreadLocal<LoginUser> loginUserThreadLocal = new ThreadLocal<>();

    // 向当前线程放对象的方法
    public static void setLoginUser(LoginUser loginUser){
        loginUserThreadLocal.set(loginUser);
    }

    // 从当前线程中获取对象的方法
    public static LoginUser getLoginUser(){
        LoginUser loginUser = loginUserThreadLocal.get();
        return loginUser;
    }

    // 将当前线程中对象移除的方法
    public static void removeLoginUser(){
        loginUserThreadLocal.remove();
    }
}
